from django.shortcuts import render
from django.http import FileResponse
import os
from rest_framework.views import APIView
from rest_framework.response import Response


# Create your views here.

class IndexView(APIView):
    def get(self, request):
        return Response({'message': 'Welcome to the API'})

    def post(self, request):

        return Response({'message': 'Welcome to the API'})

class loginByWeixin(APIView):
    def get(self, request):
        return Response({'message': 'Welcome to the API'})

    def post(self, request):
        print(request.data)

        return Response({'message': 'Welcome to the API'})

def video(request):
    # 设置视频文件的路径
    video_path = os.path.join('images/video', 'tj.gif')

    # 检查文件是否存在
    if not os.path.exists(video_path):
        return Response('Video not found')

    # 返回视频文件
    response = FileResponse(open(video_path, 'rb'))
    return response
